﻿using DigDes.DSchool.SUPS.DataAccess.Database;
using DigDes.DSchool.SUPS.DataAccess.FileLoaders;
using DigDes.DSchool.SUPS.DataAccess.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DigDes.DSchool.SUPS.BusinessLogic
{
    public class FileLoaderBC
    {
        public void LoadMyFile1(string filePath)
        {
            var loader = new MyLoader1();

            try
            {
                loader.Check(filePath);
                foreach (var row in loader.Load(filePath))
                {
                    FileLoaderDAC.DoSomething(row);
                }
            }
            catch (Exception ex)
            {
                if (ex is TypeLoadException)
                    Console.WriteLine("Invalid file type");
                else
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }
                return;
            }
           
            // Либо тоже самое через такой вызов:
            // FileLoaderDAC.DoSomething2(loader.Load(filePath));
        }
    }
}
